#include<iostream>
#include<memory>
#include"dictionary.hpp"
#include"serve.hpp"

std::string defaulttandler(const std::string& message)
{
    std::string resault="hello world";
    resault+=message;
    return resault;
}
//udeserve ip port
int main(int argc,char *argv[])
{
    if(argc!=2)
    {
        std::cout<<"form error"<<std::endl;
        std::cout<<"udpserve ip port";
        exit(1);
    }

   
    uint16_t port=std::stoi(argv[1]);
    Enable_Console_Log_Strategy();
    
    dict dictory;
    dictory.Loaddict();
    std::unique_ptr<UdpServe> usvr=std::make_unique<UdpServe>(port,[&dictory](const std::string& word,InetAddr&cli)->std::string
    {
        return dictory.Translate(word,cli);
    });
    usvr->Init();
    usvr->Start();
    return 0;
}